<template>
    <div>
        <span>{{hour}}:{{minute}}:{{second}}</span>
    </div>
</template>

<script>
  export default {
    data () {
      return {}
    },
    props: [
      'time'
    ],
    mounted () {
      this.currenttime = parseInt(this.time)
    },
    updated () {
      console.log(this.time)
      this.currenttime = parseInt(this.time)
    },
    computed: {
      hour: function () {
        let s = this.currenttime
        return this.sprintf(Math.floor(s / 3600))
      },
      minute: function () {
        let s = this.currenttime
        return this.sprintf(Math.floor(s / 60) % 60)
      },
      second: function () {
        let s = this.currenttime
        return this.sprintf(s % 60)
      },
      currenttime: function () {
        return parseInt(this.time)
      }
    },
    methods: {
      sprintf: function (value) {
        return (Array(2).join(0) + value).slice(-2)
      }
    }
  }
</script>